package com.thinkingstar.iads.uruleExample.action;

import com.bstek.urule.action.ActionId;
import com.bstek.urule.model.ExposeAction;
import com.bstek.urule.model.library.action.annotation.ActionMethod;
import com.bstek.urule.model.library.action.annotation.ActionMethodParameter;
import com.thinkingstar.iads.common.jsonUtils.AjaxResult;
import com.thinkingstar.iads.common.utils.CommonDateUtil;
import com.thinkingstar.iads.common.utils.InitSystemProperties;
import com.thinkingstar.iads.common.utils.StringUtil;
import com.thinkingstar.iads.datacenter.entity.DcEquipmentEquip;
import com.thinkingstar.iads.datacenter.entity.DcEquipmentEquipInfo;
import com.thinkingstar.iads.datacenter.entity.DcProjectDesignCell;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcEquipmentEquip;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcEquipmentEquipInfo;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcProjectDesignCell;
import com.thinkingstar.iads.projectcenter.entity.*;
import com.thinkingstar.iads.projectcenter.entity.dao.*;
import com.thinkingstar.iads.test.urule.builtIn.action.StringAction;
import com.zhuozhengsoft.pageoffice.DocumentVersion;
import org.apache.commons.lang.StringUtils;
import org.jsoup.helper.DataUtil;
import org.nutz.boot.tools.AsSpringBean;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import neu.sxc.expression.Expression;
import neu.sxc.expression.ExpressionFactory;
import neu.sxc.expression.tokens.Valuable;

import org.wltea.expression.datameta.Variable;
import org.wltea.expression.ExpressionEvaluator;
import org.wltea.expression.PreparedExpression;


@IocBean
@AsSpringBean
public class FormulaAction {

    @Inject
    Dao dao;

    @Inject
    private DaoDcProjectDesignCell daoDcProjectDesignCell;

    @Inject
    private DaoPcProjectData daoPcProjectData;

    @Inject
    private DaoPcEquipmentEquip daoPcEquipmentEquip;

    @Inject
    private DaoDcEquipmentEquipInfo daoDcEquipmentEquipInfo;

    @Inject
    private DaoPcProjectEquipmentEquipInfo daoPcProjectEquipmentEquipInfo;

    @Inject
    private DaoDcEquipmentEquip daoDcEquipmentEquip;

    @Inject
    private DaoPcEquipmentSelfCheck daoPcEquipmentSelfCheck;

    @Inject
    private DaoPcEquipmentSelfCheckResult daoPcEquipmentSelfCheckResult;

    /**
     * 套跑计算
     *
     * */
    @ExposeAction("初期套跑计算")
    public void cqtpCaculate(String project_id,String design_cell_table,List<Map> dataList){
        int xh = 1;
        List list = new ArrayList();
        for (int i=0;i<dataList.size()-2;i++){
            Map map1 = dataList.get(i);
            int rcglcq = Integer.valueOf(map1.get("rcglcq").toString()); //日车公里初期
            int sjpjyysjcq = Integer.valueOf(map1.get("sjpjyysjcq").toString());//实际平均运营时间初期
            int rcglzbcq = Integer.valueOf(map1.get("rcglzbcq").toString());//日车公里指标初期
            int yysjzb = Integer.valueOf(map1.get("yysjzb").toString());//运营时间指标
            int cqts = Integer.valueOf(map1.get("cqts").toString());//初期套数
            int sywtplcts = cqts;//剩余未套跑列车套数一开始= 被套跑的 初期套数
            String jlcd = map1.get("jlcd").toString();//交路长度
            int ytplctscq = 0;//已套跑列车套数初期
            int ytplcsylccq = 0;//已套跑列车剩余里程初期
            int ytplcsysjcq = 0;//已套跑列车剩余时间初期

            int ytprcglcq = rcglcq;//已套跑日车公里初期
            int ytpsjyysjcq = sjpjyysjcq;//已套跑实际运营时间初期

            String tpjllccq = "";//套跑交路流程初期
            for (int n=i+1;n<dataList.size()-1;n++){
                Map data = new HashMap();
                boolean sfktp = false;//是否可套跑
                Map map2 = dataList.get(n);
                int rcglcq2 = Integer.valueOf(map2.get("rcglcq").toString());//日车公里初期
                int sjpjyysjcq2 = Integer.valueOf(map2.get("sjpjyysjcq").toString());//实际运营时间初期
                int cqts2 = Integer.valueOf(map2.get("cqts").toString());//初期套数
                int jlcd2 = Integer.valueOf(map2.get("jlcd").toString());//交路长度

                //当i交路的“日车公里”+“n交路”的“日车公里”< i交路的“日车公里指标”，且i交路的“实际平均运营时间”+“n交路”的“实际平均运营时间”< i交路的“运营时间指标”，
                // n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                if(((ytprcglcq+rcglcq2)<rcglzbcq && (ytpsjyysjcq+sjpjyysjcq2)<yysjzb)){
                    ytprcglcq+= rcglcq2;
                    ytpsjyysjcq+= sjpjyysjcq2;
                    //当上面的条件满足时，进行i交路与n交路的套跑后的“剩余未套跑列车套数”计算。
                    // 当“剩余未套跑列车套数”≥0时，n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                    sywtplcts = sywtplcts -cqts2;
                    ytplctscq += cqts2;
                    ytplcsylccq += jlcd2;
                    ytplcsysjcq +=sjpjyysjcq2;
                    if (sywtplcts>=0){
                        //可套跑
                        if (StringUtils.isEmpty(tpjllccq)){
                            tpjllccq += map1.get("serial_number").toString()+"-"+map2.get("serial_number").toString();
                        } else {
                            tpjllccq+= "-"+map2.get("serial_number").toString();
                        }
                        //插入一条记录
                        data.put("id",getUUID().replaceAll("-",""));
                        data.put("project_id",project_id);
                        //序号是 xh
                        data.put("serial_number",xh);
                        //对应原交路序号初期
                        data.put("dyyjlxhcq",map1.get("serial_number").toString());
                        //套跑交路流程初期
                        data.put("tpjllccq",tpjllccq);
                        //套跑模组总里程
                        data.put("tpmzzlc",jlcd);
                        //模组总运营时间
                        data.put("mzzyysj",yysjzb);
                        //剩余未套跑列车套数初期
                        data.put("sywtplctscq",sywtplcts);
                        //已套跑列车套数初期
                        data.put("ytplctscq",cqts+"/"+ytplctscq);
                        //已套跑列车剩余里程初期
                        data.put("ytplcsylccq",jlcd+"/"+ytplcsylccq);
                        //已套跑列车剩余时间初期
                        data.put("ytplcsysjcq",sjpjyysjcq+"/"+ytplcsysjcq);
                        list.add(data);
                        xh++;
                    }
                }
            }
        }
        insertMap(list,project_id,design_cell_table);
    }

    /**
     * 套跑计算
     *
     * */
    @ExposeAction("近期套跑计算")
    public void jqtpCaculate(String project_id,String design_cell_table,List<Map> dataList){
        int xh = 1;
        List list = new ArrayList();
        for (int i=0;i<dataList.size()-2;i++){
            Map map1 = dataList.get(i);
            int rcgljq = Integer.valueOf(map1.get("rcgljq").toString()); //日车公里近期
            int sjpjyysjjq = Integer.valueOf(map1.get("sjpjyysjjq").toString());//实际平均运营时间近期
            int rcglzbjq = Integer.valueOf(map1.get("rcglzbjq").toString());//日车公里指标近期
            int yysjzb = Integer.valueOf(map1.get("yysjzb").toString());//运营时间指标
            int jqts = Integer.valueOf(map1.get("jqts").toString());//近期套数
            int sywtplcts = jqts;//剩余未套跑列车套数一开始= 被套跑的 近期套数
            String jlcd = map1.get("jlcd").toString();//交路长度
            int ytplctsjq = 0;//已套跑列车套数近期
            int ytplcsylcjq = 0;//已套跑列车剩余里程近期
            int ytplcsysjjq = 0;//已套跑列车剩余时间近期

            int ytprcgljq = rcgljq;//已套跑日车公里近期
            int ytpsjyysjjq = sjpjyysjjq;//已套跑实际运营时间近期

            String tpjllcjq = "";//套跑交路流程近期
            for (int n=i+1;n<dataList.size()-1;n++){
                Map data = new HashMap();
                boolean sfktp = false;//是否可套跑
                Map map2 = dataList.get(n);
                int rcgljq2 = Integer.valueOf(map2.get("rcgljq").toString());//日车公里近期
                int sjpjyysjjq2 = Integer.valueOf(map2.get("sjpjyysjjq").toString());//实际运营时间近期
                int jqts2 = Integer.valueOf(map2.get("jqts").toString());//近期套数
                int jlcd2 = Integer.valueOf(map2.get("jlcd").toString());//交路长度

                //当i交路的“日车公里”+“n交路”的“日车公里”< i交路的“日车公里指标”，且i交路的“实际平均运营时间”+“n交路”的“实际平均运营时间”< i交路的“运营时间指标”，
                // n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                if(((ytprcgljq+rcgljq2)<rcglzbjq && (ytpsjyysjjq+sjpjyysjjq2)<yysjzb)){
                    ytprcgljq+= rcgljq2;
                    ytpsjyysjjq+= sjpjyysjjq2;
                    //当上面的条件满足时，进行i交路与n交路的套跑后的“剩余未套跑列车套数”计算。
                    // 当“剩余未套跑列车套数”≥0时，n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                    sywtplcts = sywtplcts -jqts2;
                    ytplctsjq += jqts2;
                    ytplcsylcjq += jlcd2;
                    ytplcsysjjq +=sjpjyysjjq2;
                    if (sywtplcts>=0){
                        //可套跑
                        if (StringUtils.isEmpty(tpjllcjq)){
                            tpjllcjq += map1.get("serial_number").toString()+"-"+map2.get("serial_number").toString();
                        } else {
                            tpjllcjq+= "-"+map2.get("serial_number").toString();
                        }
                        //插入一条记录
                        data.put("id",getUUID().replaceAll("-",""));
                        data.put("project_id",project_id);
                        //序号是 xh
                        data.put("serial_number",xh);
                        //对应原交路序号近期
                        data.put("dyyjlxhjq",map1.get("serial_number").toString());
                        //套跑交路流程近期
                        data.put("tpjllcjq",tpjllcjq);
                        //套跑模组总里程
                        data.put("tpmzzlc",jlcd);
                        //模组总运营时间
                        data.put("mzzyysj",yysjzb);
                        //剩余未套跑列车套数近期
                        data.put("sywtplctsjq",sywtplcts);
                        //已套跑列车套数近期
                        data.put("ytplctsjq",jqts+"/"+ytplctsjq);
                        //已套跑列车剩余里程近期
                        data.put("ytplcsylcjq",jlcd+"/"+ytplcsylcjq);
                        //已套跑列车剩余时间近期
                        data.put("ytplcsysjcq",sjpjyysjjq+"/"+ytplcsysjjq);
                        list.add(data);
                        xh++;
                    }
                }
            }
        }
        insertMap(list,project_id,design_cell_table);
    }

    /**
     * 套跑计算
     *
     * */
    @ExposeAction("远期套跑计算")
    public void yqtpCaculate(String project_id,String design_cell_table,List<Map> dataList){
        double d = 1.3;
        System.out.println(Math.ceil(d));
        int xh = 1;
        List list = new ArrayList();
        for (int i=0;i<dataList.size()-2;i++){
            Map map1 = dataList.get(i);
            int rcglyq = Integer.valueOf(map1.get("rcglyq").toString()); //日车公里远期
            int sjpjyysjyq = Integer.valueOf(map1.get("sjpjyysjyq").toString());//实际平均运营时间远期
            int rcglzbyq = Integer.valueOf(map1.get("rcglzbyq").toString());//日车公里指标远期
            int yysjzb = Integer.valueOf(map1.get("yysjzb").toString());//运营时间指标
            int yqts = Integer.valueOf(map1.get("yqts").toString());//远期套数
            int sywtplcts = yqts;//剩余未套跑列车套数一开始= 被套跑的 远期套数
            String jlcd = map1.get("jlcd").toString();//交路长度
            int ytplctsyq = 0;//已套跑列车套数远期
            int ytplcsylcyq = 0;//已套跑列车剩余里程远期
            int ytplcsysjyq = 0;//已套跑列车剩余时间远期
            int ytprcglyq = rcglyq;//已套跑日车公里远期
            int ytpsjyysjyq = sjpjyysjyq;//已套跑实际运营时间远期
            String tpjllcyq = "";//套跑交路流程远期
            for (int n=i+1;n<dataList.size()-1;n++){
                Map data = new HashMap();
                boolean sfktp = false;//是否可套跑
                Map map2 = dataList.get(n);
                int rcglyq2 = Integer.valueOf(map2.get("rcglyq").toString());//日车公里远期
                int sjpjyysjyq2 = Integer.valueOf(map2.get("sjpjyysjyq").toString());//实际运营时间远期
                int yqts2 = Integer.valueOf(map2.get("yqts").toString());//远期套数
                int jlcd2 = Integer.valueOf(map2.get("jlcd").toString());//交路长度

                //当i交路的“日车公里”+“n交路”的“日车公里”< i交路的“日车公里指标”，且i交路的“实际平均运营时间”+“n交路”的“实际平均运营时间”< i交路的“运营时间指标”，
                // n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                if(((ytprcglyq+rcglyq2)<rcglzbyq && (ytpsjyysjyq+sjpjyysjyq2)<yysjzb)){
                    ytprcglyq+= rcglyq2;
                    ytpsjyysjyq+= sjpjyysjyq2;
                    //当上面的条件满足时，进行i交路与n交路的套跑后的“剩余未套跑列车套数”计算。
                    // 当“剩余未套跑列车套数”≥0时，n交路可以与i交路进行套跑，否则n交路不可以与i交路进行套跑。
                    sywtplcts = sywtplcts -yqts2;
                    ytplctsyq += yqts2;
                    ytplcsylcyq += jlcd2;
                    ytplcsysjyq +=sjpjyysjyq2;
                    if (sywtplcts>=0){
                        //可套跑
                        if (StringUtils.isEmpty(tpjllcyq)){
                            tpjllcyq += map1.get("serial_number").toString()+"-"+map2.get("serial_number").toString();
                        } else {
                            tpjllcyq+= "-"+map2.get("serial_number").toString();
                        }
                        //插入一条记录
                        data.put("id",getUUID().replaceAll("-",""));
                        data.put("project_id",project_id);
                        //序号是 xh
                        data.put("serial_number",xh);
                        //对应原交路序号远期
                        data.put("dyyjlxhyq",map1.get("serial_number").toString());
                        //套跑交路流程远期
                        data.put("tpjllcyq",tpjllcyq);
                        //套跑模组总里程
                        data.put("tpmzzlc",jlcd);
                        //模组总运营时间
                        data.put("mzzyysj",yysjzb);
                        //剩余未套跑列车套数远期
                        data.put("sywtplctsyq",sywtplcts);
                        //已套跑列车套数远期
                        data.put("ytplctsyq",yqts+"/"+ytplctsyq);
                        //已套跑列车剩余里程远期
                        data.put("ytplcsylcyq",jlcd+"/"+ytplcsylcyq);
                        //已套跑列车剩余时间远期
                        data.put("ytplcsysjyq",sjpjyysjyq+"/"+ytplcsysjyq);
                        list.add(data);
                        xh++;
                    }
                }
            }
        }
        insertMap(list,project_id,design_cell_table);
    }
    /**
     * 机务检修量计算
     *
     * */
    @ExposeAction("机务检修量计算之根据机车类型和单双机修改公式")
    public List<Map> updateFormulaByJclx(String jclx,String khjz,String dsjz,List<Map> formulaList){
        //机车类型（电力 内燃）
        //客机/货机 （客机 货机）
        //单机/双机 （单 双）
        Iterator<Map> it = formulaList.iterator();
        while(it.hasNext()) {
            Map map = it.next();
            if (map.get("formula_name").toString().contains("运用机车台数")){//带分母 需要替换
                if(jclx.equals("电力")){
                    if (khjz.equals("客机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__dlkjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__dlkjfm"));
                    } else if (khjz.equals("货机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__dlhjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__dlhjfm"));
                    }
                } else if (jclx.equals("内燃")){
                    if (khjz.equals("客机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__nrkjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__nrkjfm"));
                    } else if (khjz.equals("货机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__nrhjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__nrhjfm"));
                    }
                }
            } else if (map.get("formula_name").toString().contains("配属机车台数")){
                if(dsjz.equals("双")){
                    map.put("expression",map.get("expression").toString().replaceAll("__psjcxs","__sjpsjcxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__psjcxs","__sjpsjcxs"));
                }else if (dsjz.equals("单")){
                    map.put("expression",map.get("expression").toString().replaceAll("__psjcxs","__djpsjcxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__psjcxs","__djpsjcxs"));
                }
            } else if (map.get("formula_name").toString().contains("年检修机车台数")){
                if(jclx.equals("电力")){   //njxjctsxs  年检修机车台数系数  公式里带 C6 C5 C4 C3 C2 C1
                    map.put("expression",map.get("expression").toString().replaceAll("__njxjctsxs","__dlnjxjctsxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__njxjctsxs","__dlnjxjctsxs"));
                } else if (jclx.equals("内燃")){
                    map.put("expression",map.get("expression").toString().replaceAll("__njxjctsxs","__nrnjxjctsxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__njxjctsxs","__nrnjxjctsxs"));
                }
            }

        }
        return formulaList;
    }

    /**
     * 机务整备量计算
     *
     * */
    @ExposeAction("机务整备量计算之根据机车类型和单双机修改公式")
    public List<Map> updateFormulaJwzbl(String jclx,String khjz,String dsjz,List<Map> formulaList){
        //机车类型（电力 内燃）
        //客机/货机 （客机 货机）
        //单机/双机 （单 双）
        Iterator<Map> it = formulaList.iterator();
        while(it.hasNext()) {
            Map map = it.next();
            if (map.get("formula_name").toString().contains("运用机车台数")){//带分母 需要替换
                if(jclx.equals("电力")){
                    if (khjz.equals("客机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__dlkjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__dlkjfm"));
                    } else if (khjz.equals("货机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__dlhjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__dlhjfm"));
                    }
                } else if (jclx.equals("内燃")){
                    if (khjz.equals("客机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__nrkjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__nrkjfm"));
                    } else if (khjz.equals("货机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__fm","__nrhjfm"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__fm","__nrhjfm"));
                    }
                }
            } else if (map.get("formula_name").toString().contains("配属机车台数")){
                if(dsjz.equals("双")){
                    map.put("expression",map.get("expression").toString().replaceAll("__psjcxs","__sjpsjcxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__psjcxs","__sjpsjcxs"));
                } else if (dsjz.equals("单")){
                    map.put("expression",map.get("expression").toString().replaceAll("__psjcxs","__djpsjcxs"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__psjcxs","__djpsjcxs"));
                }
            } else if (map.get("formula_name").toString().contains("每昼夜整备机车台数")){
                if(jclx.equals("电力")){   //jczbzq 机车整备周期
                    map.put("expression",map.get("expression").toString().replaceAll("__jczbzq","__dljczbzq"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__jczbzq","__dljczbzq"));
                } else if (jclx.equals("内燃")){
                    map.put("expression",map.get("expression").toString().replaceAll("__jczbzq","__nrjczbzq"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__jczbzq","__nrjczbzq"));
                }
            } else if (map.get("formula_name").toString().contains("每昼夜总耗油量")){
                if(jclx.equals("电力")){   //jchyzb 机车耗油指标  电力 不计算
                    map.put("expression","");
                    map.put("constant_code","");
                } else if (jclx.equals("内燃")){
                    if (khjz.equals("客机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__jchyzb","__kjjchyzb"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__jchyzb","__kjjchyzb"));
                    } else if (khjz.equals("货机")){
                        map.put("expression",map.get("expression").toString().replaceAll("__jchyzb","__hjjchyzb"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("__jchyzb","__hjjchyzb"));
                    }
                }
            } else if (map.get("formula_name").toString().contains("每昼夜冷却水总消耗量")){
                if(jclx.equals("电力")){   //jchyzb 机车耗水指标  电力 不计算
                    map.put("expression","");
                    map.put("constant_code","");
                } else if (jclx.equals("内燃")){
                    map.put("expression",map.get("expression").toString().replaceAll("__jchshzb","__jchszb"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__jchshzb","__jchszb"));
                }
            } else if (map.get("formula_name").toString().contains("每昼夜耗砂量")){
                if(jclx.equals("电力")){   //jchyzb 机车耗油指标  电力 不计算
                    map.put("expression",map.get("expression").toString().replaceAll("__jchszb","__dljchszb"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__jchszb","__dljchszb"));
                } else if (jclx.equals("内燃")){
                    map.put("expression",map.get("expression").toString().replaceAll("__jchszb","__nrjchszb"));
                    map.put("constant_code",map.get("constant_code").toString().replaceAll("__jchszb","__nrjchszb"));
                }
            }
        }
        return formulaList;
    }

    /**
     * 工作量计算 -周转法
     * 运用车类别  交路长度  对方有无运用所
     * */
    @ExposeAction("根据运用车类别修改公式")
    public List<Map> updateFormulaByCondition(String yyclb,String jlcd,String dfywyys,List<Map> formulaList){
        //运用车类别 交路长度 对方有无运用所

        int jlcd_i = 0;
        if (StringUtils.isNotEmpty(jlcd)){
            jlcd_i = Integer.parseInt(jlcd);
        }

        Iterator<Map> it = formulaList.iterator();
        while(it.hasNext()){
            Map map = it.next();
            if (map.get("expression").toString().contains("TL_ZZFCLK02")){
                if (yyclb.equals("A")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__ddbldfyyys")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_A__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_A__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_A__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_A__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK02__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_A__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_A"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_A"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_A__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_A__zfsj"));
                    }
                } else if (yyclb.equals("B")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_B__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_B__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_B__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_B__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK02__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_B__ss500"));
                        }
                    }  else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_B"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_B"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_B__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_B__zfsj"));
                    }
                } else if (yyclb.equals("城际")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_CJ__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_CJ__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_CJ__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ddbldfyyys","TL_ZZFCLK02_CJ__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK02__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__ss","TL_ZZFCLK02_CJ__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_CJ"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02","TL_ZZFCLK02_CJ"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK02__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_CJ__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK02__zfsj","TL_ZZFCLK02_CJ__zfsj"));
                    }
                }
            }else if (map.get("expression").toString().contains("TL_ZZFCLK01")){
                if (yyclb.equals("A")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_A__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_A__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_A__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_A__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK01__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_A__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_A"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_A"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_A__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_A__zfsj"));
                    }
                } else if (yyclb.equals("B")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_B__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_B__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_B__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_B__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK01__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_B__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_B"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_B"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_B__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_B__zfsj"));
                    }
                } else if (yyclb.equals("城际")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_CJ__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_CJ__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_CJ__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ddbldfyyys","TL_ZZFCLK01_CJ__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK01__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__ss","TL_ZZFCLK01_CJ__ss500"));
                        }
                    }  else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_CJ"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01","TL_ZZFCLK01_CJ"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK01__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_CJ__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK01__zfsj","TL_ZZFCLK02_CJ__zfsj"));
                    }
                }
            }else if (map.get("expression").toString().contains("TL_ZZFCLK04")){
                if (yyclb.equals("A")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_A__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_A__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_A__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_A__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK04__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_A__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_A"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_A"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_A__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_A__zfsj"));
                    }
                } else if (yyclb.equals("B")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_B__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_B__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_B__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_B__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK04__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_B__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_B"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_B"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_B__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_B__zfsj"));
                    }
                } else if (yyclb.equals("城际")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_CJ__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_CJ__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_CJ__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ddbldfyyys","TL_ZZFCLK04_CJ__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK04__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__ss","TL_ZZFCLK04_CJ__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_CJ"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04","TL_ZZFCLK04_CJ"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK04__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_CJ__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK04__zfsj","TL_ZZFCLK04_CJ__zfsj"));
                    }
                }
            }else if (map.get("expression").toString().contains("TL_ZZFCLK03")){
                if (yyclb.equals("A")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_A__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_A__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_A__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_A__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK03__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_A__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_A"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_A"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_A__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_A__zfsj"));
                    }
                } else if (yyclb.equals("B")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_B__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_B__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_B__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_B__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK03__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_B__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_B"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_B"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_B__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_B__zfsj"));
                    }
                } else if (yyclb.equals("城际")){
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__DDBL")){
                        if (dfywyys.equals("有")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_CJ__ddbldfyyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_CJ__ddbldfyyys"));
                        } else if(dfywyys.equals("无")){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_CJ__ddbldfwyys"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ddbldfyyys","TL_ZZFCLK03_CJ__ddbldfwyys"));
                        }
                    } else if (map.get("expression").toString().contains("TL_ZZFCLK03__ss")){
                        if (jlcd_i>1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss1000"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss1000"));
                        } else if (jlcd_i>500 && jlcd_i<=1000){
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss"));
                        } else {
                            map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss500"));
                            map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__ss","TL_ZZFCLK03_CJ__ss500"));
                        }
                    } else {
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_CJ"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03","TL_ZZFCLK03_CJ"));
                    }
                    if (map.get("expression").toString().contains("TL_ZZFCLK03__zfsj")){
                        map.put("expression",map.get("expression").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_CJ__zfsj"));
                        map.put("constant_code",map.get("constant_code").toString().replaceAll("TL_ZZFCLK03__zfsj","TL_ZZFCLK03_CJ__zfsj"));
                    }
                }
            }

        }
        return formulaList;
    }

    @ExposeAction("单方向工作量计算特殊部分")
    public Map dfxgzljs(Map map,String constantCode,String project_id) {
        //运用车比例
        String yyclb = (String)map.get("yyclb");
        //对方有无运用所
        String dfyys = (String)map.get("dfyys");
        String[] constantCodes = constantCode.split(",");
        List<Map> clList = new ArrayList<>();
        //查询常量
        for (int i=0;i<constantCodes.length;i++){
            clList.addAll(getDataListBySql("select * from pc_project_constant_data d, dc_constant_version v where d.version_id=v.id and d.project_id='"+project_id+"' and v.constant_table_code='"+constantCodes[i]+"' and v.del_flag <> 1 and d.del_flag <> 1"));
        }
        String a_cq = "";
        String a_jq = "";
        String a_yq = "";
        String b_cq = "";
        String b_jq = "";
        String b_yq = "";
        String cj_cq = "";
        String cj_jq = "";
        String cj_yq = "";

        String y_cq = "";
        String y_jq = "";
        String y_yq = "";
        String w_cq = "";
        String w_jq = "";
        String w_yq = "";

        for(int n=0;n<clList.size();n++) {
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("ALCRXGLCQ")){
                a_cq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("ALCRXGLJQ")){
                a_jq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("ALCRXGLYQ")){
                a_yq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("BLCRXGLCQ")){
                b_cq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("BLCRXGLJQ")){
                b_jq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("BLCRXGLYQ")){
                b_yq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("CJLCRXGLCQ")){
                cj_cq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("CJLCRXGLJQ")){
                cj_jq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("CJLCRXGLYQ")){
                cj_yq= (String)clList.get(n).get("code_value");
            }

            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(Y)CQ")){
                y_cq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(Y)JQ")){
                y_jq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(Y)YQ")){
                y_yq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(N)CQ")){
                w_cq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(N)JQ")){
                w_jq= (String)clList.get(n).get("code_value");
            }
            if(clList.get(n).get("code_name").toString().toUpperCase().equals("DDBL(N)YQ")){
                w_yq= (String)clList.get(n).get("code_value");
            }

        }
        String rcglcq = "";
        String rcgljq = "";
        String rcglyq = "";
        if (yyclb.equals("A")) {
            rcglcq = a_cq;
            rcgljq = a_jq;
            rcglyq = a_yq;
        } else if (yyclb.equals("B")){
            rcglcq = b_cq;
            rcgljq = b_jq;
            rcglyq = b_yq;
        } else if (yyclb.equals("城际")){
            rcglcq = cj_cq;
            rcgljq = cj_jq;
            rcglyq = cj_yq;
        }
        map.put("rcglcq",rcglcq);
        map.put("rcgljq",rcgljq);
        map.put("rcglyq",rcglyq);
        String ddbl_cq = "";
        String ddbl_jq = "";
        String ddbl_yq = "";
        if (dfyys.equals("有")) {
            ddbl_cq = y_cq;
            ddbl_jq = y_jq;
            ddbl_yq = y_yq;
        } else if (dfyys.equals("无")){
            ddbl_cq = w_cq;
            ddbl_jq = w_jq;
            ddbl_yq = w_yq;
        }
        map.put("ddblcq",rcglcq);
        map.put("ddbljq",rcgljq);
        map.put("ddblyq",rcglyq);
        return map;
    }

    @ExposeAction("综合工区工程车库用电计算")
    public void calZhgqgcckyd(String sfszgcck,String sfszqzj,String project_id,String design_cell_table) {
        String sql = "delete from "+design_cell_table+" where project_id='"+project_id+"'";
        Sql sqls = Sqls.create(sql);
        dao.execute(sqls);

        String ydyq = "";
        if (sfszgcck.equals("on") && sfszqzj.equals("on")) {
            ydyq = "设5t电动单梁起重机1台，用电量10/台，AC380V，三相五线制，TN-S接地。";
        }
        if (StringUtils.isNotEmpty(ydyq)) {
            List<Map> list = new ArrayList<>();
            Map map = new HashMap();
            map.put("id",UUID.randomUUID().toString().replace("-",""));
            map.put("project_id",project_id);
            map.put("serial_number","1");
            map.put("sfszqzj","是");
            map.put("ydyq",ydyq);
            list.add(map);
            insertMap(list,project_id,design_cell_table);
        }
    }

    @ExposeAction("物资总库综合材料库用电计算")
    public void calWzzkzhclkyd(String rkfs,String project_id,String design_cell_table) {
        String sql = "delete from "+design_cell_table+" where project_id='"+project_id+"'";
        Sql sqls = Sqls.create(sql);
        dao.execute(sqls);

        String ydyq = "";
        if (rkfs.equals("辊道输送机")) {
            ydyq = "立体仓库区设立体仓储设备配电箱1处，总用电量按30*6+6*2kW考虑，AC380V，三相五线制，TN-S接地。";
        } else if (rkfs.equals("穿梭车")) {
            ydyq = "立体仓库区设立体仓储设备配电箱1处，总用电量按30*6+2*2+2*6kW考虑，AC380V，三相五线制，TN-S接地。";
        } else if (rkfs.equals("自由吊")) {
            ydyq = "立体仓库区设立体仓储设备配电箱1处，总用电量按30*6+2*2+6*1.5考虑，AC380V，三相五线制，TN-S接地。";
        }

        List<Map> list = new ArrayList<>();
        Map map = new HashMap();
        map.put("id",UUID.randomUUID().toString().replace("-",""));
        map.put("project_id",project_id);
        map.put("serial_number","1");
        map.put("rkfs",rkfs);
        map.put("ydyq",ydyq);
        list.add(map);
        insertMap(list,project_id,design_cell_table);
    }


    @ExposeAction("综合维修中心工程车库用电计算")
    public void calZhwxzxckyd(String project_id,String design_cell_table) {
        String sql = "delete from "+design_cell_table+" where project_id='"+project_id+"'";
        Sql sqls = Sqls.create(sql);
        dao.execute(sqls);

        String sqlStr = "select peei.equipment_name ,peei.equipment_num,dme.equipment_power from pc_equipment_equip_info peei " +
                ", pc_equipment_equip pee " +
                ", dc_equipment_manufacturer dem " +
                ", dc_manufacturer_equipment dme where peei.equipment_equip_id=pee.id " +
                "and peei.equipment_name in ('移动式架车机','电动单梁桥式起重机LD型,Gn=10t','电动单梁桥式起重机LD型,Gn=5t','台式砂轮机MD3212','台式钻床ZQ4116型','双人钳工台2100×750×800（mm）','除尘式砂轮机M3330','移动式空压机3W-0.8/10','交流弧焊机（一级能效）','点焊机（一级能效）','整流弧焊机（一级能效）') " +
                "and pee.project_id='"+project_id+"' " +
                "and dem.id=peei.equipment_manufacturer_id " +
                "and dme.equipment_manufacturer_id = dem.id " +
                "and dme.manufacturer_equipment_name = peei.equipment_name " +
                "and pee.equipment_equip_name like '%综合维修中心%' ";
        List<Map> list = getDataListBySql(sqlStr);
        for(int i=0;i<list.size();i++) {
            list.get(i).put("id",UUID.randomUUID().toString().replace("-",""));
            list.get(i).put("serial_number",i+1);
            list.get(i).put("project_id",project_id);
            list.get(i).put("sbmc",list.get(i).get("equipment_name"));
            list.get(i).put("sl",list.get(i).get("equipment_num"));
            if ("null".equals((String)list.get(i).get("equipment_power"))) {
                list.get(i).put("ydl","");
                list.get(i).put("yq","");
            } else if (StringUtils.isNotEmpty((String)list.get(i).get("equipment_power"))){
                String[] ydlyq = ((String) list.get(i).get("equipment_power")).split("，");
                if (ydlyq.length>1) {
                    list.get(i).put("ydl",ydlyq[0]);
                    list.get(i).put("yq",ydlyq[1]);
                } else if (ydlyq.length==1) {
                    list.get(i).put("ydl",ydlyq[0]);
                    list.get(i).put("yq","");
                } else {
                    list.get(i).put("ydl","");
                    list.get(i).put("yq","");
                }
            } else {
                list.get(i).put("ydl","");
                list.get(i).put("yq","");
            }
        }
        insertMap(list,project_id,design_cell_table);
    }

    @ExposeAction("设备自检")
    public void excuteSbzj(int jckxsjq,int jckxsyq,String project_id) {
        //获取所有自检项目List
        List<PcEquipmentSelfCheck> pcEquipmentSelfChecks = daoPcEquipmentSelfCheck.query();
        //查询项目是否已经自检过 如自检过，那么重新自检，删除原有数据
        List<PcProjectEquipmentSelfCheckResult> pcProjectEquipmentSelfCheckResults = daoPcEquipmentSelfCheckResult.query(Cnd.where("project_id","=",project_id).and("del_flag","=","0"));
        if (null!=pcProjectEquipmentSelfCheckResults && pcProjectEquipmentSelfCheckResults.size()>0) {
            //自检过，删除数据
            String sql = "delete from pc_project_equipment_selfcheck_result where project_id='"+project_id+"'";
            Sql sqls = Sqls.create(sql);
            dao.execute(sqls);
        }
        //开始自检
        if (jckxsjq<=4) {
            jckxsjq = 4;
        } else if (jckxsjq>4 && jckxsjq<=6){
            jckxsjq = 6;
        } else if (jckxsjq>6 && jckxsjq<=8) {
            jckxsjq = 8;
        } else if (jckxsjq>8 && jckxsjq<=10){
            jckxsjq = 10;
        } else if (jckxsjq>10 && jckxsjq<=12) {
            jckxsjq = 12;
        }
        int flag = 0;//不落轮镟床(双轴，含视频监控及保温装置)+转向架更换设备 数量
        int flag1 = 0;//公铁两用牵引车(电池供电) 项目里设备配备数量
        String selfcheckId = "";
        String zjxmmcStr = "";
        String zjbzStr = "";
        String bbzStr = "";
        //查询项目设备配备表
        List <PcProjectEquipmentEquip> equipmentEquips = daoPcEquipmentEquip.findEquipmentEquipByProjectId(project_id);
        if (null!=equipmentEquips && equipmentEquips.size()>0){
            List<PcProjectEquipmentEquipInfo> equipmentEquipInfos = daoPcProjectEquipmentEquipInfo.findEquipmentEquipInfoByEquipId(equipmentEquips.get(0).getId());
            for(int i=0;i<pcEquipmentSelfChecks.size();i++) {
                String zjxmmc = pcEquipmentSelfChecks.get(i).getZjxmmc();
                String zjbz = pcEquipmentSelfChecks.get(i).getZjbz();
                String bzz = pcEquipmentSelfChecks.get(i).getBzz();
                String ms = pcEquipmentSelfChecks.get(i).getMs();
                String selfcheck_id = pcEquipmentSelfChecks.get(i).getId();
                Object result = null;

                if (!zjxmmc.equals("公铁两用牵引车(电池供电)")){
                    //.replace("jckxs",Integer.toString(jckxsjq));
                    result = ExpressionEvaluator.evaluate(bzz.replace("jckxs",Integer.toString(jckxsjq)), new ArrayList<Variable>());
                }
                if (zjxmmc.equals("不落轮镟床(双轴，含视频监控及保温装置)")||zjxmmc.equals("转向架更换设备")){
                    flag += (int)result;
                }
               /* if (zjxmmc.equals("变流器冷却液加注装置")) {
                    result = Math.ceil(Double.parseDouble((String)result));
                }*/
                for(int j=0;j<equipmentEquipInfos.size();j++) {
                    if (equipmentEquipInfos.get(j).getEquipment_name().equals(zjxmmc)) {
                        if (!zjxmmc.equals("公铁两用牵引车(电池供电)")) {
                            int num = Integer.parseInt(equipmentEquipInfos.get(j).getEquipment_num());
                            if (zjbz.equals(">=")) {
                                if ((int)result<=num) {
                                    //自检通过
                                    PcProjectEquipmentSelfCheckResult pcresult = new PcProjectEquipmentSelfCheckResult();
                                    pcresult.setId(UUID.randomUUID().toString().replaceAll("-",""));
                                    pcresult.setEquipment_selfcheck_id(selfcheck_id);
                                    pcresult.setEquipment_selfcheck_xmmc(zjxmmc);
                                    pcresult.setProject_id(project_id);
                                    pcresult.setResult("自检通过");
                                    pcresult.setDel_flag(false);
                                    pcresult.setCreate_time(CommonDateUtil.getDateTime());
                                    daoPcEquipmentSelfCheckResult.insert(pcresult);
                                } else {
                                    PcProjectEquipmentSelfCheckResult pcresult = new PcProjectEquipmentSelfCheckResult();
                                    pcresult.setId(UUID.randomUUID().toString().replaceAll("-",""));
                                    pcresult.setEquipment_selfcheck_id(selfcheck_id);
                                    pcresult.setEquipment_selfcheck_xmmc(zjxmmc);
                                    pcresult.setProject_id(project_id);
                                    pcresult.setResult("自检不通过");
                                    pcresult.setReason(zjxmmc+"不满足自检标准"+zjbz+pcEquipmentSelfChecks.get(i).getMs()+",该值为"+result+"实际值为"+num);
                                    pcresult.setDel_flag(false);
                                    pcresult.setCreate_time(CommonDateUtil.getDateTime());
                                    daoPcEquipmentSelfCheckResult.insert(pcresult);
                                }
                            }
                        } else {
                            //公铁两用牵引车(电池供电)  单独判断
                            flag1 = Integer.parseInt(equipmentEquipInfos.get(j).getEquipment_num());
                            selfcheckId = selfcheck_id;
                            zjxmmcStr = zjxmmc;
                            zjbzStr = zjbz;
                            bbzStr = ms;
                        }
                    }
                }
            }
        }
        //公铁两用牵引车(电池供电) >= 不落轮镟床(双轴，含视频监控及保温装置)+转向架更换设备
        if(flag <= flag1){
            //自检通过
            PcProjectEquipmentSelfCheckResult pcresult = new PcProjectEquipmentSelfCheckResult();
            pcresult.setId(UUID.randomUUID().toString().replaceAll("-",""));
            pcresult.setEquipment_selfcheck_id(selfcheckId);
            pcresult.setEquipment_selfcheck_xmmc(zjxmmcStr);
            pcresult.setProject_id(project_id);
            pcresult.setResult("自检通过");
            pcresult.setDel_flag(false);
            pcresult.setCreate_time(CommonDateUtil.getDateTime());
            daoPcEquipmentSelfCheckResult.insert(pcresult);
        } else {
            PcProjectEquipmentSelfCheckResult pcresult = new PcProjectEquipmentSelfCheckResult();
            pcresult.setId(UUID.randomUUID().toString().replaceAll("-",""));
            pcresult.setEquipment_selfcheck_id(selfcheckId);
            pcresult.setEquipment_selfcheck_xmmc(zjxmmcStr);
            pcresult.setProject_id(project_id);
            pcresult.setResult("自检不通过");
            pcresult.setReason(zjxmmcStr+"不满足自检标准"+zjbzStr+bbzStr+",该值为"+flag1+"实际值为"+flag);
            pcresult.setDel_flag(false);
            pcresult.setCreate_time(CommonDateUtil.getDateTime());
            daoPcEquipmentSelfCheckResult.insert(pcresult);
        }
    }

    @ExposeAction("物资总库设备选型")
    public AjaxResult excuteWzzkSbxx(Map params,String project_id) {
        //根据项目id获取 项目设计阶段和设计内容
        PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
        String sfszjcj = params.get("sfszjcj").toString();//是否设置架车机
        String wzzkrkfs = params.get("wzzkrkfs").toString();//物资总库入库方式
        String zhgqsfphgdcz = params.get("zhgqsfphgdcz").toString(); //综合工区配合轨道车组
        String zhgqgdczdzc = params.get("zhgqgdczdzc").toString();//综合工区轨道车组的组成
        String zhgqsfszgcck = params.get("zhgqsfszgcck").toString();//综合工区是否设置工程车库
        String zhgqgccksfszqzj = params.get("zhgqgccksfszqzj").toString();//综合工区工程车库是否设起重机

        //先从数据中心取 三个设备表数据
        DcEquipmentEquip sbb1 = daoDcEquipmentEquip.fineEquipmentByName("综合工区设备配备",project_info.getProject_design_phase_id(),project_info.getProject_design_content_id());
        DcEquipmentEquip sbb2 = daoDcEquipmentEquip.fineEquipmentByName("综合维修中心设备配备",project_info.getProject_design_phase_id(),project_info.getProject_design_content_id());
        DcEquipmentEquip sbb3 = daoDcEquipmentEquip.fineEquipmentByName("物资总库设备配备",project_info.getProject_design_phase_id(),project_info.getProject_design_content_id());

        List<Map> eqInfos1 = daoDcEquipmentEquipInfo.getEquipmentEquipInfoByParam(sbb1.getId());
        List<Map> eqInfos2 = daoDcEquipmentEquipInfo.getEquipmentEquipInfoByParam(sbb2.getId());
        List<Map> eqInfos3 = daoDcEquipmentEquipInfo.getEquipmentEquipInfoByParam(sbb3.getId());
        //是否设置架车机
        if (sfszjcj.equals("on")) {
            //综合维修中心设备配备 不显示苏州（车辆段内）综合维修中心设备配备“综合维修中心工程车库” 电动单梁桥式起重机LD型,Gn=5t
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合维修中心工程车库") && map.get("equipment_name").equals("电动单梁桥式起重机LD型,Gn=5t")){
                    it.remove();
                }
            }
        } else if (sfszjcj.equals("off")) {
            //综合维修中心设备配备 不显示苏州（车辆段内）综合维修中心设备配备“综合维修中心工程车库”移动式架车机，
            //综合维修中心设备配备 不显示苏州（车辆段内）综合维修中心设备配备“综合维修中心工程车库”起重机LD型,Gn=10t
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合维修中心工程车库") && map.get("equipment_name").equals("移动式架车机")){
                    it.remove();
                } else if(map.get("equipment_children_type_name").equals("综合维修中心工程车库") && map.get("equipment_name").equals("起重机LD型,Gn=10t")){
                    it.remove();
                }
            }
        }
        //物资总库入库方式
        if (wzzkrkfs.equals("辊道输送机")){
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”穿梭车、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”链条输送机、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”出入库自由吊1.5t、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”出入库输送机
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("穿梭车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("链条输送机")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库自由吊1.5t")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库输送机")){
                    it.remove();
                }
            }

        } else if (wzzkrkfs.equals("穿梭车")){
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”、出入库输送系统（横向）
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”出入库自由吊1.5t、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”出入库输送机
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库输送系统（横向）")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库自由吊1.5t")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库输送机")){
                    it.remove();
                }
            }
        } else if (wzzkrkfs.equals("自由吊")){
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”出入库输送系统（横向）、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”穿梭车、
            //不显示苏州（车辆段内）物资总库设备配备“综合材料库内移动式设备”链条输送机
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("出入库输送系统（横向）")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("穿梭车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("综合材料库内移动式设备") && map.get("equipment_name").equals("链条输送机")){
                    it.remove();
                }
            }
        }
        //综合工区配合轨道车组
        if (zhgqsfphgdcz.equals("on")) {
            if (zhgqgdczdzc.equals("2轨道车2平车")){
                //2轨道车2平车→不显示苏州（停车场）综合工区设备配备“大型检测与维修车辆”携吊平车
                Iterator<Map> it = eqInfos2.iterator();
                while(it.hasNext()){
                    Map map = it.next();
                    if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("携吊平车")){
                        it.remove();
                    }
                }
            }
        } else {
            //不显示苏州（停车场）综合工区设备配备“大型检测与维修车辆”携吊平车、
            // 苏州（停车场）综合工区设备配备“大型检测与维修车辆”内燃轨道车、
            // 苏州（停车场）综合工区设备配备“大型检测与维修车辆”平板车、
            // 不显示苏州（停车场）综合工区设备配备“大型检测与维修车辆”蓄电池轨道车
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("携吊平车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("内燃轨道车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("平板车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("蓄电池轨道车")){
                    it.remove();
                }
            }
        }
        //综合工区是否设置轨道车库
        if (zhgqsfszgcck.equals("off")) {
            //不显示苏州（停车场）综合工区设备配备“大型检测与维修车辆”内燃轨道车、
            // 苏州（停车场）综合工区设备配备“大型检测与维修车辆”平板车、
            // 苏州（停车场）综合工区设备配备“大型检测与维修车辆”携吊平车
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("内燃轨道车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("平板车")){
                    it.remove();
                } else if (map.get("equipment_children_type_name").equals("大型检测与维修车辆") && map.get("equipment_name").equals("携吊平车")){
                    it.remove();
                }
            }
        }
        //综合工区工程车库是否设置起重机
        if(zhgqgccksfszqzj.equals("off")) {
            //不显示苏州（停车场）综合工区设备配备“综合维修中心工程车库”电动单梁起重机LD型,Gn=5t
            Iterator<Map> it = eqInfos2.iterator();
            while(it.hasNext()){
                Map map = it.next();
                if (map.get("equipment_children_type_name").equals("综合维修中心工程车库") && map.get("equipment_name").equals("电动单梁起重机LD型,Gn=5t")){
                    it.remove();
                }
            }
        }

        //项目中心 设备配备
        List <PcProjectEquipmentEquip> equipmentEquips = daoPcEquipmentEquip.findEquipmentEquipByProjectId(project_id);

        for (int i=0;i<equipmentEquips.size();i++) {
            //删除项目中心 pc_equipment_equip_info 三个数据
            String sql = "delete from pc_equipment_equip_info where equipment_equip_id='"+equipmentEquips.get(i).getId()+"'";
            Sql sqls = Sqls.create(sql);
            dao.execute(sqls);
        }

        //删除项目中心 pc_equipment_equip 数据
        String sql1 = "delete from pc_equipment_equip where project_id='"+project_id+"'";
        Sql sqls1 = Sqls.create(sql1);
        dao.execute(sqls1);

        //查询 物资总库网箱托盘货架数量计算结果
        List<DcProjectDesignCell> designCells = daoDcProjectDesignCell.query(Cnd.where("design_cell_table_name","like","%网箱、托盘、货架%").and("project_design_phase_id","=",project_info.getProject_design_phase_id()).and("project_design_content_id","=",project_info.getProject_design_content_id()));
        String wxtphj_name = "";
        Map<String,Object> map = null;
        if(null!=designCells && designCells.size()>0) {
            wxtphj_name =  "dc_designcell_"+designCells.get(0).getDesign_cell_table_code();
            map = getTableDataMap(wxtphj_name,project_id);
        }

        //插入 pc_equipment_equip数据
        if(null != sbb1) {
            PcProjectEquipmentEquip pcProjectEquipmentEquip = new PcProjectEquipmentEquip();
            pcProjectEquipmentEquip.setEquipment_equip_name(sbb1.getEquipment_equip_name());
            pcProjectEquipmentEquip.setEquipment_equip_code(sbb1.getEquipment_equip_code());
            pcProjectEquipmentEquip.setProject_id(project_id);
            pcProjectEquipmentEquip.setCreate_time(CommonDateUtil.getDateTime());
            pcProjectEquipmentEquip.setDel_flag(false);
            pcProjectEquipmentEquip.setId(UUID.randomUUID().toString().replaceAll("-",""));
            daoPcEquipmentEquip.insert(pcProjectEquipmentEquip);
            for (int i=0;i<eqInfos1.size();i++) {
                PcProjectEquipmentEquipInfo pcProjectEquipmentEquipInfo = new PcProjectEquipmentEquipInfo();
                Map dcEquipmentEquipInfo = eqInfos1.get(i);
                pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                pcProjectEquipmentEquipInfo.setEquipment_id(dcEquipmentEquipInfo.get("equipment_id").toString());
                pcProjectEquipmentEquipInfo.setEquipment_equip_id(pcProjectEquipmentEquip.getId());
                pcProjectEquipmentEquipInfo.setEquipment_name(dcEquipmentEquipInfo.get("equipment_name").toString());
                pcProjectEquipmentEquipInfo.setId(UUID.randomUUID().toString().replaceAll("-",""));
                pcProjectEquipmentEquipInfo.setCreate_time(CommonDateUtil.getDateTime());
                pcProjectEquipmentEquipInfo.setDel_flag(false);
                dao.insert(pcProjectEquipmentEquipInfo);
            }
        } else {
            return AjaxResult.error("数据中心无"+sbb1.getEquipment_equip_name()+"数据");
        }

        if(null != sbb2) {
            PcProjectEquipmentEquip pcProjectEquipmentEquip2 = new PcProjectEquipmentEquip();
            pcProjectEquipmentEquip2.setEquipment_equip_name(sbb2.getEquipment_equip_name());
            pcProjectEquipmentEquip2.setEquipment_equip_code(sbb2.getEquipment_equip_code());
            pcProjectEquipmentEquip2.setProject_id(project_id);
            pcProjectEquipmentEquip2.setCreate_time(CommonDateUtil.getDateTime());
            pcProjectEquipmentEquip2.setDel_flag(false);
            pcProjectEquipmentEquip2.setId(UUID.randomUUID().toString().replaceAll("-",""));
            daoPcEquipmentEquip.insert(pcProjectEquipmentEquip2);
            for (int i=0;i<eqInfos2.size();i++) {
                PcProjectEquipmentEquipInfo pcProjectEquipmentEquipInfo = new PcProjectEquipmentEquipInfo();
                Map dcEquipmentEquipInfo = eqInfos2.get(i);
                pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                pcProjectEquipmentEquipInfo.setEquipment_id(dcEquipmentEquipInfo.get("equipment_id").toString());
                pcProjectEquipmentEquipInfo.setEquipment_equip_id(pcProjectEquipmentEquip2.getId());
                pcProjectEquipmentEquipInfo.setEquipment_name(dcEquipmentEquipInfo.get("equipment_name").toString());
                pcProjectEquipmentEquipInfo.setId(UUID.randomUUID().toString().replaceAll("-",""));
                pcProjectEquipmentEquipInfo.setCreate_time(CommonDateUtil.getDateTime());
                pcProjectEquipmentEquipInfo.setDel_flag(false);
                dao.insert(pcProjectEquipmentEquipInfo);
            }
        } else {
            return AjaxResult.error("数据中心无"+sbb2.getEquipment_equip_name()+"数据");
        }

        if(null != sbb3) {
            PcProjectEquipmentEquip pcProjectEquipmentEquip3 = new PcProjectEquipmentEquip();
            pcProjectEquipmentEquip3.setEquipment_equip_name(sbb3.getEquipment_equip_name());
            pcProjectEquipmentEquip3.setEquipment_equip_code(sbb3.getEquipment_equip_code());
            pcProjectEquipmentEquip3.setProject_id(project_id);
            pcProjectEquipmentEquip3.setCreate_time(CommonDateUtil.getDateTime());
            pcProjectEquipmentEquip3.setDel_flag(false);
            pcProjectEquipmentEquip3.setId(UUID.randomUUID().toString().replaceAll("-",""));
            daoPcEquipmentEquip.insert(pcProjectEquipmentEquip3);
            for (int i=0;i<eqInfos3.size();i++) {
                PcProjectEquipmentEquipInfo pcProjectEquipmentEquipInfo = new PcProjectEquipmentEquipInfo();
                Map dcEquipmentEquipInfo = eqInfos3.get(i);
                if (null!=map){
                    if (dcEquipmentEquipInfo.get("equipment_name").toString().equals("托盘（1200×1000×160）")){
                        if (StringUtils.isNotEmpty(map.get("tpsl").toString())){
                            pcProjectEquipmentEquipInfo.setEquipment_num(map.get("tpsl").toString());
                        }else{
                            pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                        }
                    } else if (dcEquipmentEquipInfo.get("equipment_name").toString().equals("网箱（1200×1000×800）")){
                        if (StringUtils.isNotEmpty(map.get("wxsl").toString())){
                            pcProjectEquipmentEquipInfo.setEquipment_num(map.get("wxsl").toString());
                        }else{
                            pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                        }
                    } else if (dcEquipmentEquipInfo.get("equipment_name").toString().equals("立体仓库货架")){
                        if (StringUtils.isNotEmpty(map.get("hjsl").toString())){
                            pcProjectEquipmentEquipInfo.setEquipment_num(map.get("hjsl").toString());
                        }else{
                            pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                        }
                    } else {
                        pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                    }
                } else {
                    pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.get("equipment_num").toString());
                }
                pcProjectEquipmentEquipInfo.setEquipment_id(dcEquipmentEquipInfo.get("equipment_id").toString());
                pcProjectEquipmentEquipInfo.setEquipment_equip_id(pcProjectEquipmentEquip3.getId());
                pcProjectEquipmentEquipInfo.setEquipment_name(dcEquipmentEquipInfo.get("equipment_name").toString());
                pcProjectEquipmentEquipInfo.setId(UUID.randomUUID().toString().replaceAll("-",""));
                pcProjectEquipmentEquipInfo.setCreate_time(CommonDateUtil.getDateTime());
                pcProjectEquipmentEquipInfo.setDel_flag(false);
                dao.insert(pcProjectEquipmentEquipInfo);
            }
        } else {
            return AjaxResult.error("数据中心无"+sbb2.getEquipment_equip_name()+"数据");
        }
        return AjaxResult.success("初始化成功");
    }

    /**动车运用所*/
    @ExposeAction("设备选型")
    public AjaxResult excuteSbxx(int jckxsjq,int jckxsyq,String project_id) {
        //根据项目id获取 项目设计阶段和设计内容
        PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
        if (jckxsjq<=4) {
            jckxsjq = 4;
        } else if (jckxsjq>4 && jckxsjq<=6){
            jckxsjq = 6;
        } else if (jckxsjq>6 && jckxsjq<=8) {
            jckxsjq = 8;
        } else {
            jckxsjq = 10;
        }
        //1.根据检查库线数 判断 取 几线设备库
        //查询项目中心是否已经选型过 pc_equipment_equip 该项目是否有数据
        //如有，则不重新选型，如无，则查询数据中心设备库 dc_equipment_equip 满足条件的
        int line = 0;
        List <PcProjectEquipmentEquip> equipmentEquips = daoPcEquipmentEquip.findEquipmentEquipByProjectId(project_id);
        if (null!=equipmentEquips && equipmentEquips.size()>0) {
            //说明配备过. 看已经配的是几线  跟 最新的检查库线数是否匹配
            String equipment_equip_code = equipmentEquips.get(0).getEquipment_equip_code();
            if (equipment_equip_code.contains("4line")) {
                line = 4;
            } else if (equipment_equip_code.contains("6line")) {
                line = 6;
            } else if (equipment_equip_code.contains("8line")) {
                line = 8;
            } else if (equipment_equip_code.contains("10line")) {
                line = 10;
            }
            if (jckxsjq!=line) {//配备过，但是最新检查库线数改变，那么重新配备
                return insertEquipmentEquip(jckxsjq,equipmentEquips.get(0).getId(),project_id,project_info.getProject_design_phase_id(),project_info.getProject_design_content_id());
            } else {
                return AjaxResult.error("设备库线数未改变，已初始化过");
            }
        } else {//没配备过
            return insertEquipmentEquip(jckxsjq,"",project_id,project_info.getProject_design_phase_id(),project_info.getProject_design_content_id());
        }
    }

    public AjaxResult insertEquipmentEquip(int jskxsjq,String equipment_equip_id,String project_id,String phase_id,String content_id) {
        if (StringUtils.isNotEmpty(equipment_equip_id)) {
            //删除项目中心 pc_equipment_equip_info 数据
            String sql = "delete from pc_equipment_equip_info where equipment_equip_id='"+equipment_equip_id+"'";
            Sql sqls = Sqls.create(sql);
            dao.execute(sqls);
        }
        //删除项目中心 pc_equipment_equip 数据
        String sql1 = "delete from pc_equipment_equip where project_id='"+project_id+"'";
        Sql sqls1 = Sqls.create(sql1);
        dao.execute(sqls1);

        //查询数据中心 dc_equipment_equip 数据 插入项目中心
        DcEquipmentEquip equipmentEquip = daoDcEquipmentEquip.findEquipmentByParams(phase_id,content_id,jskxsjq);
        PcProjectEquipmentEquip pcProjectEquipmentEquip = new PcProjectEquipmentEquip();
        if(null != equipmentEquip) {
            pcProjectEquipmentEquip.setEquipment_equip_name(equipmentEquip.getEquipment_equip_name());
            pcProjectEquipmentEquip.setEquipment_equip_code(equipmentEquip.getEquipment_equip_code());
            pcProjectEquipmentEquip.setProject_id(project_id);
            pcProjectEquipmentEquip.setCreate_time(CommonDateUtil.getDateTime());
            pcProjectEquipmentEquip.setDel_flag(false);
            pcProjectEquipmentEquip.setId(UUID.randomUUID().toString().replaceAll("-",""));
            daoPcEquipmentEquip.insert(pcProjectEquipmentEquip);

            //查询数据中心 dc_equipment_equip_info 数据 插入 项目中心
            List<PcProjectEquipmentEquipInfo> pcProjectEquipmentEquipInfos = new ArrayList<PcProjectEquipmentEquipInfo>();
            List<DcEquipmentEquipInfo> equipmentEquipInfos = daoDcEquipmentEquipInfo.findEquipInfoByEquipId(equipmentEquip.getId());
            for (int i=0;i<equipmentEquipInfos.size();i++) {
                PcProjectEquipmentEquipInfo pcProjectEquipmentEquipInfo = new PcProjectEquipmentEquipInfo();
                DcEquipmentEquipInfo dcEquipmentEquipInfo = equipmentEquipInfos.get(i);
                pcProjectEquipmentEquipInfo.setEquipment_num(dcEquipmentEquipInfo.getEquipment_num());
                pcProjectEquipmentEquipInfo.setEquipment_id(dcEquipmentEquipInfo.getEquipment_id());
                pcProjectEquipmentEquipInfo.setEquipment_equip_id(pcProjectEquipmentEquip.getId());
                pcProjectEquipmentEquipInfo.setEquipment_name(dcEquipmentEquipInfo.getEquipment_name());
                pcProjectEquipmentEquipInfo.setId(UUID.randomUUID().toString().replaceAll("-",""));
                pcProjectEquipmentEquipInfo.setCreate_time(CommonDateUtil.getDateTime());
                pcProjectEquipmentEquipInfo.setDel_flag(false);
                dao.insert(pcProjectEquipmentEquipInfo);
            }
            return AjaxResult.success(jskxsjq+"线设备库初始化成功");
        } else {
            return AjaxResult.error("数据中心无"+jskxsjq+"线设备库");
        }
    }

    @ExposeAction("房屋计算")
    public void excuteFw(int jckxsjq,int jckxsyq,String project_id,String tableName){
        //检查库线数近期，检查库线数远期，项目ID，设计单元表名
        String design_cell_table_code = tableName.replace("dc_designcell_","");
        PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
        List<DcProjectDesignCell> list = daoDcProjectDesignCell.query(Cnd.where("design_cell_table_code","=",design_cell_table_code).and("project_design_phase_id","=",project_info.getProject_design_phase_id()).and("project_design_content_id","=",project_info.getProject_design_content_id()));
        DcProjectDesignCell designCell = null;
        if (null!=list &&list.size()>0) {
            designCell= list.get(0);
            //获取房屋常量表
            //List<Map> constantList = getConstantList(project_id,designCell.getConstant_version_ids());
            String str4 = "('4线检查库','检查库边跨','列车外皮清洗装置及控制室','轮对踏面诊断装置及控制室','不落轮镟库','临修库','滤网滤筒清洗间','空压机间')";
            String str6 = "('6线检查库','检查库边跨','列车外皮清洗装置及控制室','轮对踏面诊断装置及控制室','不落轮镟库','临修库','滤网滤筒清洗间','空压机间')";
            String str8 = "('8线检查库','检查库边跨','列车外皮清洗装置及控制室','轮对踏面诊断装置及控制室','不落轮镟库','临修库','滤网滤筒清洗间','空压机间')";
            String str10 = "('10线检查库','检查库边跨','列车外皮清洗装置及控制室','轮对踏面诊断装置及控制室','不落轮镟库','临修库','滤网滤筒清洗间','空压机间')";
           // String sql = "select pd.code_cname as mc,pc.code_cname as ckzzx,pc.code_value as jzmj from (select code_parent_name,code_cname,code_value from pc_project_constant_data where code_parent_name in (select code_name from pc_project_constant_data where code_cname in " ;
            String sql ="select a.code_cname type, group_concat(b.code_cname) code_cname , group_concat(b.code_value) code_value " +
                    "from pc_project_constant_data a inner join pc_project_constant_data b on a.code_name = b.code_parent_name where a.del_flag = '0' and b.del_flag = '0' and a.project_id='"+project_id+"' and b.project_id='"+project_id+"'";
            if (jckxsjq<=4) {
                sql += " and a.code_cname in "+str4;
            } else if (jckxsjq>4 && jckxsjq<=6){
                sql += " and a.code_cname in "+str6;
            } else if (jckxsjq>6 && jckxsjq<=8) {
                sql += " and a.code_cname in "+str8;
            } else {
                sql += " and a.code_cname in "+str10;
            }
            sql += " group by a.code_cname ";

            Sql sqls = Sqls.create(sql);
            sqls.setCallback(new SqlCallback() {
                @Override
                public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                    List<Map> list = new ArrayList<>();
                    while (rs.next()){
                        Map map = new HashMap<>();
                        map.put("mc", rs.getString("type"));
                        String[] code_cname = rs.getString("code_cname").split(",");
                        String[] code_value = rs.getString("code_value").split(",");
                        for (int i=0;i<code_cname.length;i++) {
                            if (code_cname[i].equals("建筑面积㎡")) {
                                map.put("jzmj",code_value[i]);
                            } else {
                                map.put("ckzzx",code_value[i]);
                            }
                        }
                        list.add(map);
                    }
                    return list;
                }
            });
            dao.execute(sqls);
            List<Map> result = sqls.getList(Map.class);
            for (int i=0;i<result.size();i++) {
                Map map = result.get(i);
                map.put("gyth","");
                map.put("bz","");
                map.put("project_id",project_id);
                map.put("id",UUID.randomUUID().toString().replace("-",""));
                map.put("serial_number",i+1);
            }
            Sql sqlStr = Sqls.create("delete from "+tableName+" where project_id='"+project_id+"'");
            dao.execute(sqlStr);
            insertMap(result,project_id,tableName);
        }

    }


    @ExposeAction("设计动车设施检查库线数近期")
    public int getSjdcssBySql(String project_id,String table_name) {
        String sqlStr = "select jckxsljq,jckxslyq from "+table_name+" where project_id='"+project_id+"' ";
        List<Map> list = getDataListBySql(sqlStr);
        int result = 0;
        for (int i=0;i<list.size();i++) {
            Map newMap = new HashMap();
            result = (int)newMap.get("jckxsljq");
        }
        return result;
    }
    @ExposeAction("设计动车设施检查库线数远期")
    public int getSjdcssBySql2(String project_id,String table_name) {
        String sqlStr = "select jckxslyq from "+table_name+" where project_id='"+project_id+"' ";
        List<Map> list = getDataListBySql(sqlStr);
        int result = 0;
        for (int i=0;i<list.size();i++) {
            Map newMap = new HashMap();
            result = (int)newMap.get("jckxslyq");
        }
        return result;
    }

    @ExposeAction("批量添加设计动车设施表数据到Map")
    public Map batchInsertMap(Map oldMap,Map newMap) {
        oldMap.putAll(newMap);
        return oldMap;
    }

    @ExposeAction("设计动车设施查询sql")
    public List<Map> getSjdcssTjBySql(String project_id,String table_name) {
        String sqlStr = "select * from "+table_name+" where project_id='"+project_id+"'";
        List<Map> list = getDataListBySql(sqlStr);
        return list;
    }

    @ExposeAction("枢纽工作量统计查询sql")
    public List<Map> getSngzlTjBySql(String project_id,String tableName) {
        String sqlStr = "select fx,zb, project_id ,\n" +
                "cast(sum(yycsjq) as decimal(10,2)) yycsjq ," +
                "cast(sum(yycsyq) as decimal(10,2)) yycsyq ," +
                "cast(sum(sjccxjq) as decimal(10,2)) sjccxjq," +
                "cast(sum(sjccxyq) as decimal(10,2)) sjccxyq," +
                "cast(sum(dbzyycsjq) as decimal(10,2)) dbzyycsjq," +
                "cast(sum(dbzyycsyq) as decimal(10,2)) dbzyycsyq," +
                "cast(sum(dbzpscsjq) as decimal(10,2)) dbzpscsjq," +
                "cast(sum(dbzpscsyq) as decimal(10,2)) dbzpscsyq," +
                "cast(sum(cbzyycsjq) as decimal(10,2)) cbzyycsjq," +
                "cast(sum(cbzyycsyq) as decimal(10,2)) cbzyycsyq," +
                "cast(sum(cbzpscsjq) as decimal(10,2)) cbzpscsjq," +
                "cast(sum(cbzpscsyq) as decimal(10,2)) cbzpscsyq," +
                "cast(sum(pscsljq) as decimal(10,2)) pscsljq," +
                "cast(sum(kcdsjq) as decimal(10,2)) kcdsjq," +
                "cast(sum(kcdsyq) as decimal(10,2)) kcdsyq," +
                "cast(sum(pscslyq) as decimal(10,2)) pscslyq," +
                "cast(sum(jskxjq) as decimal(10,2)) jskxjq," +
                "cast(sum(jskxyq) as decimal(10,2)) jskxyq  from "+tableName+" where project_id='"+project_id+"' GROUP BY fx,zb ";
        List<Map> list = getDataListBySql(sqlStr);
        return list;
    }

    @ExposeAction("查询检查库线数")
    public List<Map> getJskxs(String project_id,String table_name) {
        String sqlStr = "select CEILING(sum(jskxjq)) as jskxjq,CEILING(sum(jskxyq)) as jskxyq ,project_id from "+table_name+" where project_id='"+project_id+"'";
        List<Map> list = getDataListBySql(sqlStr);
        return list;
    }

    @ExposeAction("获取常量")
    public List<Map> getConstantList(String project_id,String constant_version_id) {
        //根据 常量版本库id 获取项目中心的所有常量
        String sqlStr = "select d.* from pc_project_constant_data d , dc_constant_version v where d.version_id=v.id and d.project_id='"+project_id+"' and v.id='"+constant_version_id+"' ";
        List<Map> list = getDataListBySql(sqlStr);
        return list;
    }

    @ExposeAction("获取公式")
    public List<Map> getFormulaList(String project_id,String formula_table_code){
        //根据公式集名称获取公式
        //获取项目中心的公式
        String[] formulaCodes = formula_table_code.split(",");
        List<Map> list = new ArrayList<>();
        for (int i=0;i<formulaCodes.length;i++) {
            System.out.println("project_id "+project_id);
            String sqlStr = "select d.* from pc_project_formula_data d , dc_formula_version v where d.formula_version_id=v.id and d.project_id='"+project_id+"' and v.formula_table_code='"+formulaCodes[i]+"' and d.formula_table_code=v.formula_table_code  order by d.orderBy asc";
            list.addAll(getDataListBySql(sqlStr));
        }
        return list;
    }

    @ExposeAction("物资总库定员汇总计算")
    public Map caculateDy(Map paramMap,String project_id,Map data){
        Map result = new HashMap();
        //paramList 是 组织机构信息
        //data是 专业定员数量（定员详情表）数据
        String[] zys = new String[14];//paramMap.get("zy").toString().split(",");
        for (int n=0;n<14;n++) {
            zys[n] = (String)paramMap.get("zy"+(n+1));
        }
        //工务,房建,通信,信号,供电,电扶梯0,站台门0,暖通,给排水,电力,FAS,BAS,ISCS,AFC
        int dysl = 0;
        for(int i=0;i<zys.length;i++) {
            if(null==zys[i]) {
                continue;
            }
            if (zys[i].equals("工务")){
                dysl+= Double.valueOf(data.get("gwzydy").toString()).intValue();
            } else if (zys[i].equals("房建")){
                dysl+= Double.valueOf(data.get("fjzydy").toString()).intValue();
            } else if (zys[i].equals("通信")){
                dysl+= Double.valueOf(data.get("txzydy").toString()).intValue();
            } else if (zys[i].equals("信号")){
                dysl+= Double.valueOf(data.get("xhzydy").toString()).intValue();
            } else if (zys[i].equals("供电")){
                dysl+= Double.valueOf(data.get("gdzydy").toString()).intValue();
            } else if (zys[i].equals("电扶梯")){
                //电扶梯 定员为0
                dysl+= 0;
            } else if (zys[i].equals("站台门")){
                //站台门 定员为0
                dysl+= 0;
            } else if (zys[i].equals("暖通")){
                dysl+= Double.valueOf(data.get("ntzydy").toString()).intValue();
            } else if (zys[i].equals("给排水")){
                dysl+= Double.valueOf(data.get("gpszydy").toString()).intValue();
            } else if (zys[i].equals("电力")){
                dysl+= Double.valueOf(data.get("dlzydy").toString()).intValue();
            } else if (zys[i].equals("FAS")){
                dysl+= Double.valueOf(data.get("faszydy").toString()).intValue();
            } else if (zys[i].equals("BAS")){
                dysl+= Double.valueOf(data.get("baszydy").toString()).intValue();
            } else if (zys[i].equals("ISCS")){
                dysl+= Double.valueOf(data.get("iscszydy").toString()).intValue();
            } else if (zys[i].equals("AFC")){
                dysl+= Double.valueOf(data.get("afczydy").toString()).intValue();
            } else {
                dysl+= 0;
            }
        }
        result.put("dydd",paramMap.get("dd").toString());
        result.put("dyjg",paramMap.get("jg").toString());
        result.put("dyrs",dysl);
        return result;
    }

    @ExposeAction("公式解析计算")
    public Map<String,Object> getFormulaList(List<Map> formulaList,String project_id,Map data){
        Map<String,Object> map = data;
        for (int i=0;i<formulaList.size();i++) {
            String name = formulaList.get(i).get("formula_name").toString();
            String constant = formulaList.get(i).get("constant_code").toString();
            String variate = formulaList.get(i).get("variable_code").toString();
            String expression = formulaList.get(i).get("expression").toString();
            String formula_name = formulaList.get(i).get("description").toString();
            if (StringUtils.isEmpty(expression)){
                continue;
            }
            //1.解析 公式
            ExpressionFactory factory = ExpressionFactory.getInstance();
            Expression exp = factory.getExpression(expression);
            Set<String> variableNames = exp.getVariableNames();//获取表达式里面的所有变量名和常量名

            //获取所有的常量
            String[] constants = constant.split(",");
            for(String vableName:variableNames){
                boolean flag = false;
                String vable = vableName;
                for(String cont: constants){
                    if(vableName.equals(cont.trim())){
                        flag = true;
                        vable = cont;
                        break;
                    }
                }
                if(flag){//相同就是常量
                    //获取code_name
                    String[] split = vable.split("__");
                    String code_name = split[split.length-1].trim();
                    //获取常量
                    String value = "";
                    if (vable.startsWith("TL_")) {
                        //查询常量表
                        //截取表名
                        String tableName = vable.split("__")[0];
                        List<Map> clList = getDataListBySql("select * from pc_project_constant_data d, dc_constant_version v where d.version_id=v.id and d.project_id='"+project_id+"' and v.constant_table_code='"+tableName+"' and v.del_flag <> 1 and d.del_flag <> 1");
                        for(int n=0;n<clList.size();n++) {
                            if(clList.get(n).get("code_name").equals(vable.split("__")[1])){
                                value= (String)clList.get(n).get("code_value");
                            }
                        }
                    } else {//map数据
                        value = (String)data.get(code_name.toLowerCase());
                    }
                    map.put(code_name.toLowerCase(), value);
                }else{  //不相同就是变量
                    // 取出对应的变量
                    String v = vableName.split("__")[1].toLowerCase();
                    map.put(vable.trim().split("__")[1].toLowerCase(), map.get(v));
                }

            }

            //4.5  赋值计算
            Object result1 = null;

            String var = variate.split("__")[1].toLowerCase();
            if(expression.equals(constant)){
                //简单赋值
                String zd =  constant.split("__")[1].toLowerCase();
                result1 = map.get(zd);
                map.put(var,result1);
            } else if (expression.equals(variate)) {
                String zd =  variate.split("__")[1].toLowerCase();
                result1 = map.get(zd);
                map.put(var,result1);
            } else {
                List<Variable> variables = new ArrayList<Variable>();
                Set<Entry<String, Object>> entrySet = map.entrySet();
                for (Entry<String, Object> entry : entrySet) {
                    for(String vableName:variableNames){
                        if(vableName.split("__")[1].toLowerCase().equals(entry.getKey())) {
                            System.out.println(vableName+"---"+entry.getValue().toString());
                            variables.add(Variable.createVariable(vableName,new Float(entry.getValue().toString())));
                        }
                    }

                }
                //4.7  执行表达式
                result1 = ExpressionEvaluator.evaluate(expression, variables);
                String ss = String.valueOf(result1);
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(ss) && ss.contains(".") && ss.substring(ss.indexOf("."),ss.length()-1).length()>2){
                    if(result1.getClass().getSimpleName().equals("Double")){
                        BigDecimal b = new BigDecimal((Double) result1);
                        result1 = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
                    } else {
                        BigDecimal b = new BigDecimal((float)result1);
                        result1 = b.setScale(2,BigDecimal.ROUND_HALF_UP).floatValue();
                    }
                }
            }
            map.put(var,result1);
            if (name.equals("初期套数")) {
                //2*DS_ZZFLKLCDSB__lcdscq/((TL_ZZFGZLJS__yysjzb+TL_ZZFCLK02__zfsj)/((DS_ZZFLKLCDSB__jlcd/TL_ZZFCLK02__ss)+TL_ZZFCLK02__zfsj))
                double jlcd = Double.parseDouble(map.get("jlcd").toString());
                double zfsj = Double.parseDouble(map.get("zfsj").toString());
                double ss = 0.0;
                if (jlcd>1000){
                    ss = Double.parseDouble(map.get("ss1000").toString());
                } else if (jlcd>500 && jlcd<=1000){
                    ss = Double.parseDouble(map.get("ss").toString());
                } else {
                    ss = Double.parseDouble(map.get("ss500").toString());
                }
                double lcdscq = Double.parseDouble(map.get("lcdscq").toString());
                double yysjzb = Double.parseDouble(map.get("yysjzb").toString());
                double is= Math.floor((yysjzb + zfsj) / (jlcd / ss + zfsj));
                if (is==0.0){
                    result1 = 0;
                } else {
                    result1 = Math.ceil(2 * lcdscq / is);
                }
                System.out.println(result1.toString());
                map.put(var,result1);
            }
            if (name.equals("近期套数")) {
                //2*DS_ZZFLKLCDSB__lcdsjq/((TL_ZZFGZLJS__yysjzb+TL_ZZFCLK02__zfsj)/((DS_ZZFLKLCDSB__jlcd/TL_ZZFCLK02__ss)+TL_ZZFCLK02__zfsj))
                double jlcd = Double.parseDouble(map.get("jlcd").toString());
                double zfsj = Double.parseDouble(map.get("zfsj").toString());
                double ss = 0.0;
                if (jlcd>1000){
                    ss = Double.parseDouble(map.get("ss1000").toString());
                } else if (jlcd>500 && jlcd<=1000){
                    ss = Double.parseDouble(map.get("ss").toString());
                } else {
                    ss = Double.parseDouble(map.get("ss500").toString());
                }
                double lcdsjq = Double.parseDouble(map.get("lcdsjq").toString());
                double yysjzb = Double.parseDouble(map.get("yysjzb").toString());
                double is= Math.floor((yysjzb + zfsj) / (jlcd / ss + zfsj));
                if (is==0.0){
                    result1 = 0;
                } else {
                    result1 = Math.ceil(2 * lcdsjq / is);
                }
                System.out.println(result1.toString());
                map.put(var,result1);
            }
            if (name.equals("远期套数")) {
                //2*DS_ZZFLKLCDSB__lcdsyq/((TL_ZZFGZLJS__yysjzb+TL_ZZFCLK02__zfsj)/((DS_ZZFLKLCDSB__jlcd/TL_ZZFCLK02__ss)+TL_ZZFCLK02__zfsj))
                double jlcd = Double.parseDouble(map.get("jlcd").toString());
                double zfsj = Double.parseDouble(map.get("zfsj").toString());
                double ss = 0.0;
                if (jlcd>1000){
                    ss = Double.parseDouble(map.get("ss1000").toString());
                } else if (jlcd>500 && jlcd<=1000){
                    ss = Double.parseDouble(map.get("ss").toString());
                } else {
                    ss = Double.parseDouble(map.get("ss500").toString());
                }
                double lcdsyq = Double.parseDouble(map.get("lcdsyq").toString());
                double yysjzb = Double.parseDouble(map.get("yysjzb").toString());
                double is= Math.floor((yysjzb + zfsj) / (jlcd / ss + zfsj));
                if (is==0.0){
                    result1 = 0;
                } else {
                    result1 = Math.ceil(2 * lcdsyq / is);
                }
                System.out.println(result1.toString());
                map.put(var,result1);
            }

        }

        return map;
    }

    @ExposeAction("根据表名和项目id获取表数据")
    public List<Map> getTableDataList(String tableName,String project_id) {
        String sqlStr = "select * from "+tableName+" where project_id= '"+project_id+"' ";
        if(tableName.contains("designcell")){
            sqlStr+=" order by serial_number+0 asc";
        }
        List<Map> list = getDataListBySql(sqlStr);
        return list;
    }

    @ExposeAction("根据表名和项目id获取表数据Map")
    public Map<String,Object> getTableDataMap(String tableName,String project_id) {
        String sqlStr = "select * from "+tableName+" where project_id= '"+project_id+"'";
        List<Map> list = getDataListBySql(sqlStr);
        if(null!=list &&list.size()>0) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @ExposeAction("计算数据存储")
    public AjaxResult insertMap(List<Map> map,String project_id,String tableName){

        //先删除指定表 对应 project_id的数据
        String sql = "delete from "+tableName+" where project_id='"+project_id+"'";
        Sql sqls = Sqls.create(sql);
        dao.execute(sqls);

        //开始插入新计算数据
        String sqlStr = "select * from information_schema.`COLUMNS` where TABLE_NAME='"+tableName+"' and TABLE_SCHEMA='"+ InitSystemProperties.getTableSchema()+"'";
        List<Map> list = getDataListBySql(sqlStr);

        List<Map> newList = new ArrayList<Map>();
        for (int i=0;i<map.size();i++) {
            Map newMap = new HashMap();
            for(int k=0;k<list.size();k++) {
                String column = (String) list.get(k).get("COLUMN_NAME");
                if(null != list.get(k).get("COLUMN_DEFAULT") && StringUtils.isNotEmpty((String)list.get(k).get("COLUMN_DEFAULT"))){
                    if(null==map.get(i).get(column) || StringUtils.isEmpty((String)map.get(i).get(column))) {
                        newMap.put(column,list.get(k).get("COLUMN_DEFAULT"));
                    }
                } else {
                    newMap.put(column,map.get(i).get(column));
                }
            }
            newList.add(newMap);
        }

        Sql sql2 = Sqls.create("delete from "+tableName+" where project_id='"+project_id+"'");
        dao.execute(sql2);

        if (null != newList &&newList.size()>0) {
            newList.get(0).put(".table",tableName);
            dao.insert(newList);
        }
        return AjaxResult.success();
    }

    public List<Map> getDataListBySql(String sqlStr){
        Sql sql = Sqls.create(sqlStr);
        sql.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                List<Map<String,Object>> list = new ArrayList<>();
                while (rs.next()){
                    Map<String,Object> map = new HashMap<>();
                    ResultSetMetaData metaData = rs.getMetaData();
                    int count = metaData.getColumnCount();
                    for (int i = count; i > 0; i--) {
                        String filed = metaData.getColumnName(i);
                        map.put(filed, rs.getString(filed));
                    }
                    list.add(map);
                }
                return list;
            }
        });
        dao.execute(sql);
        List<Map> list = sql.getList(Map.class);
        return list;
    }

    /**
     * 保留N位小数
     * str1  原数据
     * str2 小数位数
     * */
    public Double getDouble(Double str1,int str2){
        BigDecimal b = new BigDecimal(str1);
        double f1 = b.setScale(str2, BigDecimal.ROUND_HALF_UP).doubleValue();
        return f1;
    }

    /**
     *获取UUID()
     * */
    @ExposeAction("获取UUID")
    public String getUUID(){
        String uuid = UUID.randomUUID().toString(); //获取UUID并转化为String对象
        uuid = uuid.replace("-", "");
        return uuid;
    }

    /**
     * 查询项目是否大架修
     * */
    @ExposeAction("查询项目是否大架修")
    public String getIfDjx(String project_id){
        String sqlStr = "select sfkldjx from dc_mention_xmzyjsbz where project_id='"+project_id+"' ";
        List<Map> list = getDataListBySql(sqlStr);
        String result = "";
        for (int i=0;i<list.size();i++) {
            Map newMap = list.get(i);
            result = (String)newMap.get("sfkldjx");
        }
        return result;
    }

    /***
     * 筛选大架修的公式
     *
     */
    @ExposeAction("获取有无大架修公式")
    public Map getHwslGs(List<Map> listMap,String sfdjx){
        Map map = null;
        for (int i=0;i<listMap.size();i++) {
            if (sfdjx.equals("on")) {
                if(listMap.get(i).get("formula_name").toString().contains("有大架修）")) {
                    map = listMap.get(i);
                }
            } else {
                if(listMap.get(i).get("formula_name").toString().contains("无大架修")) {
                    map = listMap.get(i);
                }
            }
        }
        return map;
    }

    /***
     *
     *判断 综合工区工程车库面积计算
     */
    @ExposeAction("综合工区工程车库面积计算")
    public Map zhgqgczkmjjs(Map param){
        //综合工区是否配合轨道车组 zhgqsfphgdcz
        //综合工区是否设置工程车库 zhgqsfszgcck
        //轨道车组 zhgqgdczdzc
        if(param.get("zhgqsfphgdcz").toString().equals("on")&&param.get("zhgqsfszgcck").toString().equals("on")) {
            if (param.get("zhgqgdczdzc").toString().equals("2轨道车2平车2携吊平车")) {
                param.put("gdcz","2轨道车2平车2携吊平车");
                param.put("fwmj","72m*18m");
                param.put("tfx","2条停放线");
            } else {
                param.put("gdcz","2轨道车2平车");
                param.put("fwmj","72m*13m");
                param.put("tfx","2条停放线");
            }
        } else if (param.get("zhgqsfphgdcz").toString().equals("off")&&param.get("zhgqsfszgcck").toString().equals("on")){
            param.put("gdcz","无");
            param.put("fwmj","无");
            param.put("tfx","1条停放线");
        }
        return param;
    }

    /***
     * 计算结果向上取整
     *
     */
    @ExposeAction("计算结果向上取整")
    public Map valueXsqz(Map<String,Object> map){
        System.out.println("第三种：通过Map.entrySet遍历key和value");
        for (Map.Entry<String,Object> entry : map.entrySet()) {
            System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
            if(null!=entry.getValue()&&!"".equals(entry.getValue())) {
                Pattern p=Pattern.compile("^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$");
                Matcher m=p.matcher(entry.getValue().toString());
                boolean b=m.matches();
                if(b) {//说明是小数
                    //向上取整
                    double val = Math.ceil(Double.parseDouble(entry.getValue().toString()));
                    int v = Double.valueOf(val).intValue();
                    entry.setValue(v);
                }
            }
        }
        return map;
    }

}
